using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace S.M.SmartMedical.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class AddHospitalAreasTable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "HospitalAreas",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Phone = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSelfServiceEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Tags = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Longitude = table.Column<decimal>(type: "decimal(10,7)", nullable: true),
                    Latitude = table.Column<decimal>(type: "decimal(10,7)", nullable: true),
                    SortOrder = table.Column<int>(type: "int", nullable: false),
                    IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreateUserName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdateUserName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HospitalAreas", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_HospitalAreas_IsEnabled",
                table: "HospitalAreas",
                column: "IsEnabled");

            migrationBuilder.CreateIndex(
                name: "IX_HospitalAreas_IsSelfServiceEnabled",
                table: "HospitalAreas",
                column: "IsSelfServiceEnabled");

            migrationBuilder.CreateIndex(
                name: "IX_HospitalAreas_Name",
                table: "HospitalAreas",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IX_HospitalAreas_SortOrder",
                table: "HospitalAreas",
                column: "SortOrder");

            // 插入初始测试数据
            migrationBuilder.InsertData(
                table: "HospitalAreas",
                columns: new[] { "Name", "Address", "Phone", "Description", "IsSelfServiceEnabled", "Tags", "Longitude", "Latitude", "SortOrder", "IsEnabled", "CreateTime", "IsDeleted" },
                values: new object[,]
                {
                    {
                        "北京协和医院",
                        "北京市东城区东单帅府园1号",
                        "010-69156114",
                        "国家卫生健康委直属的三级甲等综合医院",
                        true,
                        "三甲,综合医院,内科,外科,妇科,儿科",
                        116.4074m,
                        39.9042m,
                        1,
                        true,
                        DateTime.Now,
                        false
                    },
                    {
                        "北京大学第一医院",
                        "北京市西城区西什库大街8号",
                        "010-83572211",
                        "北京大学第一医院创建于1915年，是一所融医疗、教学、科研、预防为一体的大型综合性三级甲等医院",
                        true,
                        "三甲,综合医院,泌尿外科,肾内科,皮肤科",
                        116.3833m,
                        39.9289m,
                        2,
                        true,
                        DateTime.Now,
                        false
                    },
                    {
                        "北京天坛医院",
                        "北京市丰台区南四环西路119号",
                        "010-59978114",
                        "首都医科大学附属北京天坛医院，以神经外科为特色的三级甲等综合医院",
                        true,
                        "三甲,神经外科,神经内科,急诊科",
                        116.3969m,
                        39.8648m,
                        3,
                        true,
                        DateTime.Now,
                        false
                    },
                    {
                        "北京朝阳医院",
                        "北京市朝阳区工人体育场南路8号",
                        "010-85231000",
                        "首都医科大学附属北京朝阳医院，综合性三级甲等医院",
                        false,
                        "三甲,综合医院,呼吸科,心内科,消化科",
                        116.4551m,
                        39.9208m,
                        4,
                        true,
                        DateTime.Now,
                        false
                    },
                    {
                        "北京儿童医院",
                        "北京市西城区南礼士路56号",
                        "010-59616161",
                        "首都医科大学附属北京儿童医院，专业儿童医院",
                        true,
                        "三甲,儿童医院,儿科,新生儿科,小儿外科",
                        116.3447m,
                        39.9031m,
                        5,
                        true,
                        DateTime.Now,
                        false
                    }
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "HospitalAreas");
        }
    }
}
